import jsonschema

# 定义待校验数据
resp = {"success": True,
        "code": 10000,
        "message": "操作成功"}
# 定义规则 -- 预期结果
schema = {
    "type": "object",
    "properties":
        {"success": {"type": "boolean"},
         "code": {"type": "integer"},
         "message": {"type": "string"}},
    "required": ["success", "code", "message"]
}

# 效验规则，校验实际结果与预期规则是否相符
res = jsonschema.validate(instance=resp, schema=schema)
print(res)
